package jp.co.sharp.android.decome;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class TopActivity extends Activity {
    
    private static final int REQ_GET_PHOTO = 1;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    
    /**
     * ギャラリーを呼び出す
     */
    public void callGallery(View v) {
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        startActivityForResult(intent, REQ_GET_PHOTO);
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && requestCode == REQ_GET_PHOTO) {
            // 編集画面を呼び出す
            Uri uri = data.getData();
            Intent intent = new Intent(this, EditPhoto.class);
            intent.setData(uri);
            startActivity(intent);
        }
    }
}